var iCurrent=0,
    oNum,
	oLis,
    oImgs;
function changeImg(){
	for (var i=0,len=oLis.length;i<len;i++){
		oLis[i].className="";
		oImgs[i].className="";
	}			
	oLis[iCurrent].className="hot";
	oImgs[iCurrent].className="hot";
	iCurrent=(++iCurrent)%len;
}
function slide(id,interval){
	oNum=document.querySelector("#"+id+" .slide_num");
	oLis=document.querySelectorAll("#"+id+" .slide_num li");
	oImgs=document.querySelectorAll("#"+id+" .slide_image img");
	var iTimer=setInterval(changeImg,interval);
	
	for (var i=0,len=oLis.length;i<len;i++){
		oLis[i].index=i; 
		oLis[i].onmouseover=function (){
			clearInterval(iTimer);
			iCurrent=this.index; //此处不能直接写iCurrent=i;，因为在循环体中的函数内部访问外部循环控制变量i时，任何时刻i的值总等于终值+1。要正确取得i的值，使用oLis[i].index=i;先保存i的值是一种方法
			changeImg();			
		}
	}

	oNum.onmouseout=function (){
		iTimer=setInterval(changeImg,interval);
	}
	oNum.onmouseover=function (){
		clearInterval(iTimer);
	}	
}
window.onload=function (){
	slide("slide",2000);
}
